import random
answer = random.randint(0, 9)
N = 1
while True:
    try:
        guessing = int(input("请输入0-9间的一个整数:"))
        if guessing > answer:
            print("遗憾，太大了")
            N = N + 1
        elif guessing < answer:
            print("遗憾，太小了")
            N = N + 1
        else:
            print("预测{}次，你猜中了！".format(N))
            break
    except ValueError:
        print("输入内容必须为整数！")